From 09e3aed7704fdafbe649f422fed9dd00bb705a4f Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Thu, 6 Sep 2012 22:12:44 +0200 Subject: [PATCH] St: don't focus hidden actors If an actors is not mapped (visible and all parents visible), then don't allow navigating focus to it. This fixes a regression in the keyboard navigation of the panel with invisibile items. https://bugzilla.gnome.org/show_bug.cgi?id=683529 --- src/shell-stack.c | 11 +++++++++-- src/st/st-bin.c | 11 +++++++++-- src/st/st-entry.c | 3 ++- src/st/st-widget.c | 27 ++++++++++++--------------- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/shell-stack.c b/src/shell-stack.c index 55d5d03af..c75aae8a4 100644 --- a/src/shell-stack.c +++ b/src/shell-stack.c @@ -155,8 +155,15 @@ shell_stack_navigate_focus (StWidget *widget, if (from && clutter_actor_contains (CLUTTER_ACTOR (widget), from)) return FALSE; - clutter_actor_grab_key_focus (CLUTTER_ACTOR (widget)); - return TRUE; + if (CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (widget))) + { + clutter_actor_grab_key_focus (CLUTTER_ACTOR (widget)); + return TRUE; + } + else + { + return FALSE; + } } top_actor = clutter_actor_get_last_child (CLUTTER_ACTOR (widget)); diff --git a/src/st/st-bin.c b/src/st/st-bin.c index 3bfa93d87..a2a67bb31 100644 --- a/src/st/st-bin.c +++ b/src/st/st-bin.c @@ -200,8 +200,15 @@ st_bin_navigate_focus (StWidget *widget, if (from && clutter_actor_contains (bin_actor, from)) return FALSE; - clutter_actor_grab_key_focus (bin_actor); - return TRUE; + if (CLUTTER_ACTOR_IS_MAPPED (bin_actor)) + { + clutter_actor_grab_key_focus (bin_actor); + return TRUE; + } + else + { + return FALSE; + } } else if (priv->child && ST_IS_WIDGET (priv->child)) return st_widget_navigate_focus (ST_WIDGET (priv->child), from, direction, FALSE); diff --git a/src/st/st-entry.c b/src/st/st-entry.c index e4c35a286..c6b8701f8 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -284,7 +284,8 @@ st_entry_navigate_focus (StWidget *widget, if (from == priv->entry) return FALSE; - else if (st_widget_get_can_focus (widget)) + else if (st_widget_get_can_focus (widget) && + CLUTTER_ACTOR_IS_MAPPED (priv->entry)) { clutter_actor_grab_key_focus (priv->entry); return TRUE; diff --git a/src/st/st-widget.c b/src/st/st-widget.c index 717268abb..c867f7d44 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -763,18 +763,7 @@ st_widget_get_paint_volume (ClutterActor *self, static GList * st_widget_real_get_focus_chain (StWidget *widget) { - ClutterActorIter iter; - ClutterActor *child; - GList *focus_chain = NULL; - - clutter_actor_iter_init (&iter, CLUTTER_ACTOR (widget)); - while (clutter_actor_iter_next (&iter, &child)) - { - if (CLUTTER_ACTOR_IS_VISIBLE (child)) - focus_chain = g_list_prepend (focus_chain, child); - } - - return g_list_reverse (focus_chain); + return clutter_actor_get_children (CLUTTER_ACTOR (widget)); } @@ -1898,9 +1887,17 @@ st_widget_real_navigate_focus (StWidget *widget, { if (!focus_child) { - /* Accept focus from outside */ - clutter_actor_grab_key_focus (widget_actor); - return TRUE; + if (CLUTTER_ACTOR_IS_MAPPED (widget_actor)) + { + /* Accept focus from outside */ + clutter_actor_grab_key_focus (widget_actor); + return TRUE; + } + else + { + /* Refuse to set focus on hidden actors */ + return FALSE; + } } else { -- 2.39.5